#include <stdio.h>
#include "h/hotel.h"

int menu(void)
{
    int code, status;

    printf("\n%s\n", STARS);
    printf("Enter the number of the desired hotel:\n");
    printf("1) Fairfield Hotel             2) Hotel Olympic\n");
    printf("3) Chertworthy Plaza           4) The Stockton\n");
    printf("5) quit.\n");

    printf("%s\n", STARS);
    while ((status = scanf("%d", &code)) !=1 || (code < 1 || code > 5)) {
        printf("Enter an integer from 1 to 5, please.\n");

        if (status != 1)
            scanf("%*s");
    }
    return code;
}


int getnight(void)
{
    int night, status;

    printf("how many nights are needed? \n");
    while ((status = scanf("%d", &night)) != 1 || night <= 0) {
        if (status != 1)
            scanf("%*s");

        printf("Please enter an positive integer, such 2.\n");
    }

    return night;
}

void showprice(int night, double rate)
{
    int n;
    double onenight, total, factor;

    for (total = 0.0, factor = 1.0, n=1; n<=night; ++n, factor *= DISCOUNT) {
        onenight = rate * factor;
        printf("The %d night, need money $%.2lf\n", n, onenight);
        total += onenight;
    }

    printf("You need to pay $%.2lf in all.\n", total);
}
